/**
 *
 * Copyright 2012 TeleNav, Inc. All rights reserved.
 * SettingActivity.java
 *
 */
package com.telenav.snowsweeper;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

/**
 *@author hhzhu
 *@date 2012-12-7
 */
public class SettingActivity extends Activity
{
    private TextView tv ;
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.setting_view); 
        
        tv = (TextView)this.findViewById(R.id.server_url);
        tv.setText( UrlsOfServer.getInsttance().getSite());
        
        Button save = (Button)this.findViewById(R.id.save_config);
        save.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                String url = tv.getText().toString();

                if (!UrlsOfServer.getInsttance().setSiteConfig(url))
                {
                    Toast.makeText(SettingActivity.this, "server address wrong format!", Toast.LENGTH_LONG).show();
                }
                else
                {
                    SettingActivity.this.finish();
                }
            }
        });

    }
}
